#!/usr/bin/python
# -*- coding: utf-8 -*-
# @version        : 1.0
# @Create Time    : 2024/8/16 17:07
# @File           : task
# @IDE            : PyCharm
# @desc           : 描述

from sqlalchemy import Boolean, ForeignKey, String, Integer, Text, JSON
from sqlalchemy.orm import Mapped, mapped_column, relationship

from db.db_base import BaseModel, AuditModel


class DCTaskAssignUsers(AuditModel):
    __tablename__ = "dc_dispatch_assign_users"
    __table_args__ = ({"comment": "生产派工"})

    ticket_id: Mapped[int] = mapped_column(
        String(50),
        ForeignKey("dc_dispatch_task.ticket_id", ondelete="CASCADE"),
        comment="工单ID"
    )
    task = relationship("DCTask", foreign_keys=ticket_id, back_populates="assign_users")

    team: Mapped[str] = mapped_column(String(50), comment="分配的用户班组")
    userid: Mapped[str] = mapped_column(String(20), comment="分配用户，工号")
    username: Mapped[str] = mapped_column(String(20), comment="分配用户，姓名")
    send_message: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否已发送通知")
    remark: Mapped[str] = mapped_column(Text, nullable=True, comment="备注")
